unit indices;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, dbTables, DbiProcs, StdCtrls, DB;




type
  TForm1 = class(TForm)
    Button1: TButton;
    contas: TTable;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin

//contas.Close;
//contas.exclusive := true;
//contas.open;
//dbiRegenIndexes(contas.Handle);
//contas.exclusive := false;
//contas.close;

button1.Caption := 'Contas';
contas.tablename := 'contas.db';
contas.addindex('contas','codigo',[ixprimary]);

button1.Caption := 'Hp';
contas.TableName := 'hp.db';
contas.addindex('hp','codigo',[ixprimary]);

button1.Caption := 'Diario';
contas.TableName := 'diario.db';
contas.AddIndex('diario','lancamento',[ixprimary]);

button1.Caption := 'Clientes';
contas.TableName := 'clientes.db';
contas.AddIndex('clientes','codigo',[ixprimary]);

button1.Caption := 'Contas a Pagar - Cpagar';
contas.TableName := 'cpagar.db';
contas.AddIndex('cpagar','registro',[ixprimary]);

button1.Caption := 'Contas a Pagar - pagar';
contas.TableName := 'pagar.db';
contas.AddIndex('pagar','registro',[ixprimary]);


button1.Caption := 'Razao';
contas.TableName := 'razao.db';
repeat { until successful or Cancel button is pressed }
  try
    contas.Exclusive := True; { See if it will open }
    contas.Active    := True;
    contas.EmptyTable;
    Break; { If no error, exit the loop }
  except
    on EDatabaseError do
      if Application.MessageBox('Nao posso abrir em modo exclusivo','Open Error',
        MB_OKCANCEL + MB_DEFBUTTON1) <> IDOK then
        raise;
{ Otherwise resume the repeat loop }
  end;
until False;
contas.AddIndex('razao','lancamento',[ixprimary]);




close;

end;
end.
